<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/Home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/Cost' }">费用类目</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/OtherCost' }">其他收付款</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/DischargeSettlement' }">出院结算</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/OccupancyFee' }">入住缴费</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <!--搜索框11-->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入长者姓名" clearable v-model="name" @clear="search">
            <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          <el-button type="primary" @click="openAddOutApplication">创建出院结算</el-button>
        </el-col>
      </el-row>
      <!--修改外出申请-->

      <el-dialog top="15px" :visible.sync="modifyOutFormVisible" width="60%" title="修改出院结算" @close="closeModifyOutForm" :close-on-click-modal="false">
        <el-dialog
            width="75%"
            title="选择长者信息"
            :visible.sync="innerVisible"
            append-to-body>
          <el-input placeholder="请输入长者姓名" clearable v-model="olderName" @clear="searchOlder">
            <el-button slot="append" icon="el-icon-search" @click="searchOlder"></el-button>
          </el-input>
          <el-pagination
              @size-change="olderSizeChange"
              @current-change="olderCurrentChange"
              :current-page="olderPageNum"
              :page-sizes="[3, 6 , 12, 24]"
              :page-size="olderPageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="olderTotal"
          ></el-pagination>
          <template>
            <el-table
                :data="olderList"
                style="width: 100%"
                :row-class-name="tableRowClassName"
            >
              <el-table-column
                  label="编号"
                  type="index"
                  width="60">
              </el-table-column>
              <el-table-column
                  prop="name"
                  label="长者姓名"
                  width="100">
              </el-table-column>
              <el-table-column
                  prop="sex"
                  label="性别"
                  width="100">
              </el-table-column>
              <el-table-column
                  prop="bed.bedname"
                  label="床位号"
                  width="100">
              </el-table-column>
              <el-table-column
                  prop="idcard"
                  label="长者身份证号"
                  width="220">
              </el-table-column>
              <el-table-column
                  prop="checkdate"
                  label="入住日期"
                  width="150">
              </el-table-column>
              <el-table-column
                  label="在院状态"
                  width="120"
              >
                <template slot-scope="scope">
                  <span style="color: red" v-if="scope.row.status == 0">退房</span>
                  <span style="color: green" v-if="scope.row.status == 1">入住</span>
                  <span style="color: red" v-if="scope.row.status == 2">待退房</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="240">
                <template slot-scope="scope">
                  <el-button
                      size="mini"
                      v-if="scope.row.status != 0"
                      @click="selectOlderAdd(scope.row.id,scope.row.name)">选择
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-dialog>
        <div style="border: 1px solid #ccc">
        <h3 class="form-title">长者信息</h3>
        <el-form style="margin-bottom: 20px" ref="modifyOutForm" :rules="modifyOutFormRules" :model="modifyOutForm" label-width="150px" class="form">

          <el-form-item label="长者" prop="older.name" @click="innerVisible = true">
            <el-button style="width: 80px;height: 30px;line-height: 8px" type="primary" v-model="modifyOutForm.olderId" @click="innerVisible = true">
              {{ modifyOutForm.older.name }}
            </el-button>
          </el-form-item>

          <el-form-item label="登记日期" prop="registrationdate">
            <el-date-picker
                v-model="modifyOutForm.registrationdate"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-d"
                :editable="false"
                type="datetime"
                placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="结算日期" prop="settlementdate">
            <el-date-picker
                v-model="modifyOutForm.settlementdate"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-d"
                :editable="false"
                type="datetime"
                placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
          <div class="table-container">
            <el-table :data="tableData" style="width: 100%">
              <el-table-column align="center" prop="number" label="卡号"></el-table-column>
              <el-table-column align="center" prop="balance" label="余额"></el-table-column>
              <el-table-column
                  label="状态"
                  align="center"
                  width="80"
              >
                <template slot-scope="scope">
                  <span style="color: green" v-if="scope.row.status == 1">正常</span>
                  <span style="color: red" v-if="scope.row.status == 2">挂失</span>
                  <span style="color: red" v-if="scope.row.status == 3">冻结</span>
                  <span style="color: red" v-if="scope.row.status == 4">注销</span>
                </template>
              </el-table-column>
              <el-table-column align="center" prop="openDate" label="开通日期"></el-table-column>
            </el-table>
          </div>
        <h3 class="form-title">结算账单信息</h3>
          <el-form-item style="margin-top: 10px" label="应退款金额">
            <el-input disabled v-model="modifyOutForm.shouldrefund"></el-input>
          </el-form-item>
          <el-form-item label="实际退款金额" prop="actualrefund">
            <el-input v-model="modifyOutForm.actualrefund"></el-input>
          </el-form-item>
        </el-form></div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="closeModifyOutForm">取 消</el-button>
          <el-button type="primary" @click="modifyOutFormOK">确 定</el-button>
        </div>
      </el-dialog>
      <!--主体数据-->
      <template>
        <el-table
            :data="OutApplicationList"
            style="width: 100%"
            :row-class-name="tableRowClassName"

        >
          <el-table-column
              label="编号"
              type="index"
              width="60"
              align="center">
          </el-table-column>
          <el-table-column
              prop="older.name"
              label="长者姓名"
              width="90"
              align="center">
          </el-table-column>
          <el-table-column
              prop="older.sex"
              label="长者性别"
              width="90"
              align="center">
          </el-table-column>
          <el-table-column
              prop="older.idcard"
              label="长者身份证号"
              align="center"
              width="180">
          </el-table-column>
          <el-table-column
              prop="older.checkdate"
              label="入住时间"
              align="center"
              width="100">
          </el-table-column>
          <el-table-column
              prop="registrationdate"
              label="登记时间"
              align="center"
              width="100">
          </el-table-column>
          <el-table-column
              prop="settlementdate"
              label="结算时间"
              align="center"
              width="100">
          </el-table-column>
          <el-table-column
              prop="shouldrefund"
              label="因退款金额"
              align="center"
              width="100">
          </el-table-column>
          <el-table-column
              prop="actualrefund"
              label="实际退款金额"
              align="center"
              width="100">
          </el-table-column>
          <el-table-column
              label="状态"
              align="center"
              width="80"
          >
            <template slot-scope="scope">
              <span style="color: green" v-if="scope.row.status == 1">已结算</span>
              <span style="color: red" v-if="scope.row.status == 0">待结算</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="操作" width="220">
            <template slot-scope="scope">
              <div class="button-container">
                <el-button
                    style="margin-left: 10px"
                    size="mini"
                    type="success"
                    @click="showDate(scope.row)">查看详情
                </el-button>
                <el-button
                  size="mini"
                  v-if="scope.row.status == 0"
                  @click="handleEdit(scope.row)">编辑
              </el-button>
                <el-button
                    style="margin-left: 10px;margin-top: 5px"
                  size="mini"
                  type="primary"
                  v-if="scope.row.status == 0"
                  @click="handleGoBack(scope.row.id)">立即结算
              </el-button>
                <el-button
                    size="mini"
                    type="danger"
                    v-if="scope.row.status == 0"
                    @click="handleDelete(scope.row.id)">删除
                </el-button>

              </div>

            </template>
          </el-table-column>
        </el-table>
      </template>
      <!--分页-->
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          :page-sizes="[6, 12 , 18, 24]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
      ></el-pagination>
      <!--添加外出申请-->
      <el-dialog top="15px" :visible.sync="addOutFormVisible" title="添加出院结算" width="60%" @close="closeAddOutForm" :close-on-click-modal="false">
        <el-dialog
            width="75%"
            title="选择长者信息"
            :visible.sync="innerVisible"
            append-to-body>
          <el-input placeholder="请输入长者姓名" clearable v-model="olderName" @clear="searchOlder">
            <el-button slot="append" icon="el-icon-search" @click="searchOlder"></el-button>
          </el-input>
          <el-pagination
              @size-change="olderSizeChange"
              @current-change="olderCurrentChange"
              :current-page="olderPageNum"
              :page-sizes="[3, 6 , 12, 24]"
              :page-size="olderPageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="olderTotal"
          ></el-pagination>
          <template>
            <el-table
                :data="olderList"
                style="width: 100%"
                :row-class-name="tableRowClassName"
            >
              <el-table-column
                  label="编号"
                  type="index"
                  width="60">
              </el-table-column>
              <el-table-column
                  prop="name"
                  label="长者姓名"
                  width="100">
              </el-table-column>
              <el-table-column
                  prop="sex"
                  label="性别"
                  width="100">
              </el-table-column>
              <el-table-column
                  prop="bed.bedname"
                  label="床位号"
                  width="100">
              </el-table-column>
              <el-table-column
                  prop="idcard"
                  label="长者身份证号"
                  width="220">
              </el-table-column>
              <el-table-column
                  prop="checkdate"
                  label="入住日期"
                  width="150">
              </el-table-column>
              <el-table-column
                  label="在院状态"
                  width="120"
              >
                <template slot-scope="scope">
                  <span style="color: red" v-if="scope.row.status == 0">退房</span>
                  <span style="color: green" v-if="scope.row.status == 1">入住</span>
                  <span style="color: red" v-if="scope.row.status == 2">待退房</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="240">
                <template slot-scope="scope">
                  <el-button
                      size="mini"
                      v-if="scope.row.status != 0"
                      @click="selectOlderAdd(scope.row.id,scope.row.name)">选择
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-dialog>
        <div style="border: 1px solid #ccc">
          <h3 class="form-title">长者信息</h3>
          <el-form style="margin-bottom: 20px" ref="addOutForm" :rules="addOutFormRules" :model="addOutForm" label-width="150px" class="form">

            <el-form-item label="长者" prop="name" @click="innerVisible = true">
              <el-button v-model="addOutForm.name" style="width: 80px;height: 30px;line-height: 10px" type="danger" @click="innerVisible = true">
                {{ addOutForm.name }}
              </el-button>
            </el-form-item>

            <el-form-item label="登记日期" prop="registrationdate">
              <el-date-picker
                  v-model="addOutForm.registrationdate"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-d"
                  :editable="false"
                  type="datetime"
                  placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="结算日期" prop="settlementdate">
              <el-date-picker
                  v-model="addOutForm.settlementdate"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-d"
                  :editable="false"
                  type="datetime"
                  placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <div class="table-container">
              <el-table :data="tableData" style="width: 100%">
                <el-table-column align="center" prop="number" label="卡号"></el-table-column>
                <el-table-column align="center" prop="balance" label="余额"></el-table-column>
                <el-table-column
                    label="状态"
                    align="center"
                    width="80"
                >
                  <template slot-scope="scope">
                    <span style="color: green" v-if="scope.row.status == 1">正常</span>
                    <span style="color: red" v-if="scope.row.status == 2">挂失</span>
                    <span style="color: red" v-if="scope.row.status == 3">冻结</span>
                    <span style="color: red" v-if="scope.row.status == 4">注销</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="openDate" label="开通日期"></el-table-column>
              </el-table>
            </div>
            <h3 class="form-title">结算账单信息</h3>
            <el-form-item style="margin-top: 10px"  label="应退款金额">
              <el-input disabled v-model="addOutForm.shouldrefund"></el-input>
            </el-form-item>
            <el-form-item label="实际退款金额" prop="actualrefund">
              <el-input v-model="addOutForm.actualrefund"></el-input>
            </el-form-item>
          </el-form></div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="closeAddOutForm">取 消</el-button>
          <el-button type="primary" @click="AddOutFormOK">确 定</el-button>
        </div>
      </el-dialog>
<!--      展示信息-->
      <el-dialog top="40px"  :visible.sync="showDataFormVisible" title="添加出院结算" width="60%" @close="closeShowDataForm" :close-on-click-modal="false">
          <h3 class="form-title">长者信息</h3>
          <el-form disabled  style="margin-bottom: 20px" ref="addOutForm"  :model="showDataForm" label-width="150px" class="form">
            <el-form-item  label="长者" prop="name" @click="innerVisible = true">
              <el-input v-model="showDataForm.older.name"></el-input>
            </el-form-item>
            <el-form-item label="登记日期" prop="registrationDate">
              <el-date-picker
                  v-model="showDataForm.registrationdate"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-d"
                  :editable="false"
                  type="datetime"
                  placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="结算日期" prop="settlementDate">
              <el-date-picker
                  v-model="showDataForm.settlementdate"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-d"
                  :editable="false"
                  type="datetime"
                  placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item style="margin-top: 10px"  label="应退款金额">
            <el-input disabled v-model="showDataForm.shouldrefund"></el-input>
          </el-form-item>
            <el-form-item label="实际退款金额" prop="actualRefund">
              <el-input v-model="showDataForm.actualrefund"></el-input>
            </el-form-item>
            <div class="table-container">
              <h3 class="form-title">长者IC卡信息</h3>
              <el-table :data="tableData" style="width: 100%">
                <el-table-column align="center" prop="number" label="卡号"></el-table-column>
                <el-table-column align="center" prop="balance" label="余额"></el-table-column>
                <el-table-column
                    label="状态"
                    align="center"
                    width="80"
                >
                  <template slot-scope="scope">
                    <span style="color: green" v-if="scope.row.status == 1">正常</span>
                    <span style="color: red" v-if="scope.row.status == 2">挂失</span>
                    <span style="color: red" v-if="scope.row.status == 3">冻结</span>
                    <span style="color: red" v-if="scope.row.status == 4">注销</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" prop="openDate" label="开通日期"></el-table-column>
              </el-table>
            </div>
          </el-form>
      </el-dialog>

    </el-card>
  </div>
</template>

<script>
import {toRefs} from "vue";

export default {
  data() {
    return {
      addOutForm: {
        name:'',
        olderId: 0,
        actualrefund:'',
        shouldrefund:'',
        settlementdate:'',
        registrationdate:'',
      },
      dialogVisible: false,
      tableData: [
      ],
      olderName: '',
      olderList: [],
      innerVisible: false,

      modifyOutForm: {
        olderId: 0,
        actualrefund:'',
        shouldrefund:'',
        settlementdate:'',
        registrationdate:'',
        older: {
          name: '',
        },
      },
      showDataForm:{
        older:{name:''}
      },
      OutApplicationList: [],
      modifyOutFormVisible: false,
      showDataFormVisible: false,
      goBackOutFormVisible: false,
      addOutFormVisible: false,
      name: '',
      pageNum: 1,
      olderPageNum: 1,
      pageSize: 6,
      olderPageSize: 3,
      total: 0,
      olderTotal: 0,
      addOutFormRules: {
        registrationdate: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        name: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        settlementdate: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        actualrefund: [{required: true, message: "不能为空", trigger: 'blur'},
          {pattern: /^[+]{0,1}(\d+)$/, message: "必须是大于0的整数", trigger: 'blur'}
        ],
      },
      modifyOutFormRules: {
        registrationdate: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        name: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        settlementdate: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        actualrefund: [
          {required: true, message: "不能为空", trigger: 'blur'},
          {pattern: /^[+]{0,1}(\d+)$/, message: "必须是大于0的整数", trigger: 'blur'}
        ],
      },
      goBackOutForm: {
        id: 0,
        backdatetime: '',
      },
    };
  },
  methods: {
    showDate(row){
      console.log(row)
      this.showDataFormVisible=true
      this.showDataForm=row
      let urll = "/card/selectCardById/"+row.olderId;
      this.$axios.get(urll).then((res) => {
        if (res.data.code == 200) {
          this.tableData = res.data.data;
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error',
            duration: 1000
          });
        }
      })
    },
    openDialog() {
      this.dialogVisible = true;
    },
    tableRowClassName({rowIndex}) {
      if (rowIndex === 0) {
        return 'white-row'; // 第一行为白色
      } else if (rowIndex % 4 === 1) {
        return 'warning-row'; // 第二行和每隔三行后的行为绿色
      } else if (rowIndex % 2 === 0) {
        return ''; // 第二行和每隔三行后的行为绿色
      } else if (rowIndex % 3 === 2) {
        return 'white-row'; // 第三行和每隔三行后的行为白色
      } else {
        return 'success-row'; // 每隔三行后的行为黄色
      }
    },

    handleDelete(id) {
      this.$confirm("你确定要删除此记录吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        let url = '/discharge/deleteDischarge/'+id;
        this.$axios.get(url).then((res) => {
          if (res.data.code == 200) {
            this.$message({
              message: res.data.msg,
              type: 'success',
              duration: 1000
            });
            this.initOutApplicationList();
          } else {
            this.$message({
              message: res.data.msg,
              type: 'error',
              duration: 1000
            });
          }
        })
      }).catch(() => {
        this.$message({
          type: "info",
          message: "取消成功"
        })
      })

    },
    openAddOutApplication(id) {
      this.addOutFormVisible = true;
      this.addOutForm = {};
    },
    closeAddOutForm() {
      this.tableData=[]
      this.addOutFormVisible = false;
    },
    closeShowDataForm(){
      this.tableData=[]
      this.showDataFormVisible = false;
    },
    //打开结算修改框
    handleGoBack(id) {
      this.$confirm("你确定要结算吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        let url = '/discharge/settlementDischarge/'+id;
        this.$axios.get(url).then((res) => {
          if (res.data.code == 200) {
            this.$message({
              message: res.data.msg,
              type: 'success',
              duration: 1000
            });
            this.initOutApplicationList();
          } else {
            this.$message({
              message: res.data.msg,
              type: 'error',
              duration: 1000
            });
          }
        })
      }).catch(() => {
        this.$message({
          type: "info",
          message: "取消成功"
        })
      })
    },
    //选择长者
    // selectOlder(id, name) {
    //
    //   this.modifyOutForm.olderId = id;
    //
    //   this.modifyOutForm.older.name = name;
    //   console.log(this.modifyOutForm)
    //
    //   this.innerVisible = false;
    // },
    selectOlderAdd(id, name) {
      //console.log(this.modifyOutForm)


      this.addOutForm.olderId = id;
      this.modifyOutForm.olderId = id;
      this.modifyOutForm.older.name = name;
      this.$set(this.addOutForm,"name",name);
      this.$refs.addOutForm.validateField('name');
     // console.log(this.modifyOutForm)
      let url = "/card/selectCardById/" + id;
      let sum=0;
      this.$axios.get(url).then((res) => {
        if (res.data.code == 200) {
          this.tableData = res.data.data;
          for (let re of res.data.data) {
           // console.log(re.balance)
            sum+=re.balance;
          }
          console.log(sum)
          this.addOutForm.shouldrefund=sum
          this.$set(this.addOutForm, 'actualrefund', sum);
          this.modifyOutForm.shouldrefund=sum
          this.$set(this.modifyOutForm, 'actualrefund', sum);
          //console.log(this.addOutForm.outremark)
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error',
            duration: 1000
          });
        }
      })

      this.innerVisible = false;
    },
    //修改申请表
    handleEdit(row) {
      //console.log(row)
      this.modifyOutFormVisible = true;
      let urll = "/card/selectCardById/"+row.olderId;
      this.$axios.get(urll).then((res) => {
        if (res.data.code == 200) {
          this.tableData = res.data.data;
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error',
            duration: 1000
          });
        }
      })
      let url = "/discharge/selectDischargeById/" + row.id;
      this.$axios.get(url).then((res) => {
        if (res.data.code == 200) {
          this.modifyOutForm = res.data.data;
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error',
            duration: 1000
          });
        }
      })
    },
    //确认添加
    AddOutFormOK() {
      console.log(this.addOutForm)
      this.$refs.addOutForm.validate((vaild) => {
        if (!vaild) {
          return
        } else {
          this.$confirm("你确定要创建吗？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(() => {
            let url = '/discharge/insertDischarge'
            this.$axios.post(url, this.addOutForm).then((res) => {
              if (res.data.code == 200) {
                this.$message({
                  message: res.data.msg,
                  type: 'success',
                  duration: 1000
                });
                this.initOutApplicationList();
                this.addOutFormVisible = false;
              } else {
                this.$message({
                  message: res.data.msg,
                  type: 'error',
                  duration: 1000
                });
              }
            })
          }).catch(() => {
            this.$message({
              type: "info",
              message: "取消成功"
            })
          })
        }
      })
    },
    //确认修改
    modifyOutFormOK() {
      console.log(this.modifyOutForm)
      this.$refs.modifyOutForm.validate((valid) => {
        if (!valid) {
          return
        } else {
          let url = '/discharge/updateDischarge'
          this.$axios.post(url, this.modifyOutForm).then((res) => {
            if (res.data.code == 200) {
              this.$message({
                message: res.data.msg,
                type: 'success',
                duration: 1000
              });
              this.initOutApplicationList();
              this.modifyOutFormVisible = false;
            } else {
              this.$message({
                message: res.data.msg,
                type: 'error',
                duration: 1000
              });
            }
          })
        }
      })
    },

    //关闭修改对话框
    closeModifyOutForm() {
      this.tableData=[]
      this.modifyOutFormVisible = false;
    },
    //查询长者
    search() {
      this.pageNum = 1;
      this.initOutApplicationList();
    },
    //长者内置搜收框
    searchOlder() {
      this.olderPageNum = 1;
      this.initOlderList();
    },
    //初始化长者信息
    initOlderList() {
      let url = "/Older/list"
      this.$axios.get(url, {
        params: {
          name: this.olderName,
          now: this.olderPageNum,
          size: this.olderPageSize
        }
      }).then((res) => {
        if (res.data.code == 200) {
          this.olderList = res.data.data.list;
          this.olderPageNum = res.data.data.pageNum;
          this.olderPageSize = res.data.data.pageSize;
          this.olderTotal = res.data.data.total;
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error',
            duration: 1000
          });
        }
      })
    },
    //初始化查询外出申请数据
    initOutApplicationList() {
      let url = "/discharge/selectDischarge"
      this.$axios.get(url, {
        params: {
          name: this.name,
          now: this.pageNum,
          size: this.pageSize
        }
      }).then((res) => {
        if (res.data.code == 200) {
          console.log(res.data.data.list)
          this.OutApplicationList = res.data.data.list;
          this.pageNum = res.data.data.pageNum;
          this.pageSize = res.data.data.pageSize;
          this.total = res.data.data.total;
        } else {
          this.$message({
            message: res.data.msg,
            type: 'error',
            duration: 1000
          });
        }
      })
    },
    //改变条数查询
    handleSizeChange(size) {
      this.pageSize = size;
      this.pageNum = 1;
      this.initOutApplicationList();
    },
    //改变长者条数查询
    olderSizeChange(size) {
      this.olderPageSize = size;
      this.olderPageNum = 1;
      this.initOlderList();
    },
    //改变页数查询
    handleCurrentChange(now) {
      this.pageNum = now;
      this.initOutApplicationList();
    },
    //改变长者页数查询
    olderCurrentChange(now) {
      this.olderPageNum = now;
      this.initOlderList();
    },
  },
  created() {
    this.initOutApplicationList();
    this.initOlderList();
  }
}
</script>

<style>
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
.form-container {
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 20px;
}
.form1-container {
  margin-bottom: 40px;
}
.table-container {
  border: 1px solid #ccc;
  padding: 10px;
  text-align: center;
  margin-bottom: 40px;
}
.el-table {
  margin: 0 auto;
}
.el-button {
  background-color: #409eff;
  color: #fff;
}
.el-button:hover {
  background-color: #66b1ff;
}

</style>